package com.zzl.service;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.system.common.mapper.BisCashRecordMapper;
import com.system.common.pojo.BisCashRecord;
import com.system.common.pojo.BisCashRecordExample;
import com.system.common.pojo.BisCashRecordExample.Criteria;
@Service
public class BisCashRecordServiceImpl implements BisCashRecordService{
	@Autowired
	private BisCashRecordMapper mapper;
	@Override
	public List<BisCashRecord> listAll(Map<String, Object> map) {
		String  orderId=(String) map.get("qorderId");
		String customUserId=(String) map.get("qcustomUserId");
		@SuppressWarnings("unused")
		String customUserName=(String) map.get("qcustomUserName");
		String  payWay=(String) map.get("qpayWay");
		String recordTypPpe=(String) map.get("qrecordTypPpe");
		String startTime=(String) map.get("qstartTime");
		String endTime=(String) map.get("qendTime");
		SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
		BisCashRecordExample example=new BisCashRecordExample();
		Criteria criteria=example.createCriteria();
		if (StringUtils.isNotBlank(orderId)) {
			criteria.andOrderIdEqualTo(orderId);
		}
		if (StringUtils.isNotBlank(customUserId)) {
			criteria.andCustomUserIdEqualTo(customUserId);
		}
		if (StringUtils.isNotBlank(payWay)) {
			criteria.andRecordTypeEqualTo(payWay);
		}
		if (StringUtils.isNotBlank(recordTypPpe)) {
			criteria.andRecordTypeEqualTo(recordTypPpe);
		}
		
		try {
			if (StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)) {
				criteria.andPayTimeBetween(df.parse(startTime), df.parse(endTime));
			}
			
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		List<BisCashRecord> list=mapper.selectByExample(example);
		return list;
	}
	@Override
	public List<BisCashRecord> select(Map<String, Object> map) {
		
		return mapper.selectAll(map);
	}

}
